package com.youxin.infra.io;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.youxin.infra.entity.Item;
import org.apache.kafka.common.serialization.Serializer;

import java.sql.Timestamp;

public class ItemSerializer implements Serializer<Item> {
    @Override
    public byte[] serialize(String topic, Item data) {
        return JSON.toJSONBytes(data);
    }

    public static void main(String[] args) {
        String message=new Item(1,"1",11,new Timestamp(System.currentTimeMillis())).toString();
        System.out.println(message);
        Item item=JSONObject.parseObject(JSON.toJSONBytes(message),Item.class);
        System.out.println(item.toString());
    }
}
